package com.lvtulife.common.util.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DB {
	private static String sDriver;
	private static String sURL;
	private static String sUser;
	private static String sPass;

	static {
		Configuration rc = new Configuration("jdbc.properties");// 相对路径
		sDriver = rc.getValue("jdbc.driverClassName");// 以下读取properties文件的值
		sURL = rc.getValue("jdbc.url");
		sUser = rc.getValue("jdbc.username");
		sPass = rc.getValue("jdbc.password");
	}

	public static Connection getConn() throws SQLException {
		Connection conn = null;
		try {
			Class.forName(sDriver);
		} catch (ClassNotFoundException e) {
			throw new SQLException("JDBC CLASS ERR");
		}
		conn = DriverManager.getConnection(sURL, sUser, sPass);
		return conn;
	}
}